home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00012_GasGauge Parent.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  2.2 KB  |  81 lines

  1. property startH, maxV, endH, minV, increment, gasLevel, currentV, channel, shape, firstTime
  2. global gMenuObject
  3.  
  4. on birth me
  5.   set firstTime to 1
  6.   set channel to 24
  7.   set shape to the number of cast "gasIndicator"
  8.   return me
  9. end
  10.  
  11. on initGasGauge me
  12.   if firstTime then
  13.     set spriteRect to the rect of sprite channel
  14.     set startH to getAt(spriteRect, 1)
  15.     set maxV to getAt(spriteRect, 2)
  16.     set endH to getAt(spriteRect, 3)
  17.     set minV to getAt(spriteRect, 4)
  18.     set currentV to maxV
  19.     set firstTime to 0
  20.   end if
  21. end
  22.  
  23. on resetGasGauge me, howManyMoves
  24.   set maxValue to howManyMoves + integer(howManyMoves * 0.25)
  25.   set increment to 1.0 * (minV - maxV) / maxValue
  26.   set gasLevel to maxValue
  27.   set currentV to maxV
  28. end
  29.  
  30. on fixGasChannel me
  31.   set the stretch of sprite channel to 0
  32.   set the type of sprite channel to 1
  33.   set the foreColor of sprite channel to 255
  34. end
  35.  
  36. on reduceGasGauge me
  37.   set gasLevel to gasLevel - 1
  38.   if gasLevel > 0 then
  39.     set currentV to currentV + increment
  40.   else
  41.     set currentV to minV
  42.   end if
  43. end
  44.  
  45. on predrawGasGauge me
  46.   set the castNum of sprite channel to shape
  47.   set the rect of sprite channel to rect(startH, currentV, endH, minV)
  48.   set the foreColor of sprite channel to 185
  49.   puppetSprite(channel, 1)
  50. end
  51.  
  52. on updateGasGauge me
  53.   set the rect of sprite channel to rect(startH, currentV, endH, minV)
  54. end
  55.  
  56. on saveGasGauge me
  57.   set gasData to EMPTY
  58.   repeat with data in [startH, maxV, endH, minV, increment, gasLevel, currentV]
  59.     set gasData to gasData & string(data) & ","
  60.   end repeat
  61.   return gasData
  62. end
  63.  
  64. on loadGasGauge me, index
  65.   set startH to value(item index of the dataString of gMenuObject)
  66.   set index to index + 1
  67.   set maxV to value(item index of the dataString of gMenuObject)
  68.   set index to index + 1
  69.   set endH to value(item index of the dataString of gMenuObject)
  70.   set index to index + 1
  71.   set minV to value(item index of the dataString of gMenuObject)
  72.   set index to index + 1
  73.   set increment to value(item index of the dataString of gMenuObject)
  74.   set index to index + 1
  75.   set gasLevel to value(item index of the dataString of gMenuObject)
  76.   set index to index + 1
  77.   set currentV to value(item index of the dataString of gMenuObject)
  78.   set index to index + 1
  79.   return index
  80. end
  81.